<template>
	<van-action-sheet
		v-model:show="apply.visible"
		title="申请会议"
	>
		<van-form @submit="clickSubmit">
			<van-cell-group inset>
				<van-field
					v-model="params.topic"
					label="会议主题"
					placeholder="请输入会议主题"
					:rules="[{ required: true, message: '请输入会议主题' }]"
				/>

				<van-field
					v-model="params.meetingTime"
					label="会议时间"
					placeholder="请选择会议开始时间"
					:rules="[{ required: true, message: '请选择会议开始时间' }]"
				/>
				<van-field
					label="会议形式"
					name="radio"
					:rules="[{ required: true, message: '请选择会议形式' }]"
				>
					<template #input>
						<van-radio-group v-model="params.type" direction="horizontal">
							<van-radio v-if="meetingSetting.allowOnline != 1" :name="0">线下会</van-radio>
							<van-radio v-if="meetingSetting.allowOnline != 2" :name="1">线上会</van-radio>
						</van-radio-group>
					</template>
  				</van-field>

				<van-field
					v-for="item in params.speaker"
					v-model="item.value"
					:label="item.label"
					placeholder="请选择参会讲者"
					:rules="[{ required: true, message: '请选择参会讲者' }]"
				/>

				<van-field
					v-model="params.speaker[0]"
					label="主席"
					placeholder="请选择会议主席"
					:rules="[{ required: true, message: '请选择会议主席' }]"
				/>
			</van-cell-group>
			<div style="margin: 16px;">
				<van-button round block type="primary" native-type="submit">提交</van-button>
			</div>
		</van-form>
	</van-action-sheet>
</template>

<script setup>
import { useStore } from 'vuex'
import { ref, reactive, inject } from "vue";

const api = inject('api')
const store = useStore()

const apply = reactive({
	visible: false
})
const meetingSetting = ref({})

const params = reactive({
	topic: '',
	meetingTime: '',
	type: '',
	speaker: []
})

// 获取会议设置
const getMeetingSetting = async () => {
	const res = await api.meetingGetSetting(store.getters['user/getUserInfo'].projectId)
	if (!res.code) {
		meetingSetting.value = JSON.parse(res.data)
	}
}

const init = () => {
	apply.visible = true
	getMeetingSetting()
}

// 点击提交
const clickSubmit = () => {}

defineExpose({ init })
</script>

<style lang="less" scoped>
@import "../../less/config/var";
</style>
